package leetcode.backtrace;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Lc78_2 {

    List<List<Integer>> ans;
    List<Integer> list;

    public List<List<Integer>> subsets(int[] nums) {

        ans = new ArrayList<>();
        list = new ArrayList<>();
        ans.add(new ArrayList<>());
        getSubSets(nums, 0);
        return ans;
    }

    private void getSubSets(int[] nums, int start) {
        for (int i = start; i < nums.length; i++) {
            list.add(nums[i]);
            ans.add(new ArrayList<>(list));
            getSubSets(nums, i + 1);
            list.remove(list.size() - 1);
        }
    }
}
